<?php
/**
 * This file is part of Swoft.
 *
 * @link     https://swoft.org
 * @document https://swoft.org/docs
 * @contact  group@swoft.org
 * @license  https://github.com/swoft-cloud/swoft/blob/master/LICENSE
 */
use App\Middlewares\CorsMiddleware;
use Swoft\Http\Server\HttpServer;
use Swoft\Task\Swoole\TaskListener;
use Swoft\Task\Swoole\FinishListener;
use Swoft\Rpc\Client\Client as ServiceClient;
use Swoft\Rpc\Client\Pool as ServicePool;
use Swoft\Server\SwooleEvent;
use Swoft\Redis\RedisDb;
use Swoft\Db\Database;
use Swoft\Db\Pool;

return [ 
		'noticeHandler' => [ 
				'logFile' => '@runtime/logs/notice-%d{Y-m-d-H}.log' 
		],
		'applicationHandler' => [ 
				'logFile' => '@runtime/logs/error-%d{Y-m-d}.log' 
		],
		'logger' => [ 
				'flushRequest' => true,
				'enable' => true,
				'json' => false 
		],
		'httpServer' => [ 
				'class' => HttpServer::class,
				'port' => 9502,
				
				'process' => [					// 'monitor' => bean(MonitorProcess::class)
					// 'crontab' => bean(CrontabProcess::class)
				],
				'on' => [ 
						// SwooleEvent::TASK => bean(SyncTaskListener::class), // Enable sync task
						SwooleEvent::TASK => bean ( TaskListener::class ), // Enable task must task and finish event
						SwooleEvent::FINISH => bean ( FinishListener::class ) 
				],
		        /* @see HttpServer::$setting */
		        'setting' => [ 
						'task_worker_num' => 1,
						'task_enable_coroutine' => true,
						'worker_num' => 4 
				] 
		],
		'httpDispatcher' => [ 
				// Add global http middleware
				'middlewares' => [ 
						// \Swoft\Whoops\WhoopsMiddleware::class,
						CorsMiddleware::class,
				],
				'afterMiddlewares' => [ 
						\Swoft\Http\Server\Middleware\ValidatorMiddleware::class 
				] 
		],
		
		'redis' => [ 
				'class' => RedisDb::class,
				'host' => '127.0.0.1',
				'port' => 6379,
				'database' => 1,
				'option' => [ 
						'prefix' => 'swoft:' 
				] 
		],
		'redis.pool'     => [
				'class'   => \Swoft\Redis\Pool::class,
				'redisDb' => \bean('redis'),
				'minActive'   => 10,
				'maxActive'   => 20,
				'maxWait'     => 0,
				'maxWaitTime' => 0,
				'maxIdleTime' => 60,
		],
// 		//lFnlayew%8zl
// 		'redis-user' => [
// 				'class' => RedisDb::class,
// 				'host' => '127.0.0.1',
// 				'port' => 6379,
// 				'database' => 2,
// 				'option' => [
// 						'prefix' => 'swoft:'
// 				]
// 		],
// 		'redis.user.pool'     => [
// 				'class'   => \Swoft\Redis\Pool::class,
// 				'redisDb' => \bean('redis-user'),
// 				'minActive'   => 10,
// 				'maxActive'   => 20,
// 				'maxWait'     => 0,
// 				'maxWaitTime' => 0,
// 				'maxIdleTime' => 60,
// 		],
		'user' => [ 
				'class' => ServiceClient::class,
				'host' => '127.0.0.1',
				'port' => 18306,
				'setting' => [ 
						'timeout' => 0.5,
						'connect_timeout' => 1.0,
						'write_timeout' => 10.0,
						'read_timeout' => 0.5 
				],
				'packet' => bean ( 'rpcClientPacket' ) 
		],
		'user.pool' => [ 
				'class' => ServicePool::class,
				'client' => bean ( 'user' ) 
		],
	
		'cliRouter' => [			// 'disabledGroups' => ['demo', 'test'],
		] 
];
